#include <iostream>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

char map[16][16];

struct Point
{
    enum Direction
    {
        up,
        right,
        down,
        left
    };

    int x;
    int y;
    Direction dir = up;

    bool equal(Point point)
    {
        return x == point.x && y == point.y;
    }

    void move()
    {
        switch (dir)
        {
            case up:
                if (x == 0 || map[x - 1][y] == '*')
                {
                    dir = right;
                    // move();
                }
                else
                {
                    x--;
                }
                break;
            case right:
                if (y == 9 || map[x][y + 1] == '*')
                {
                    dir = down;
                    // move();
                }
                else
                {
                    y++;
                }
                break;
            case down:
                if (x == 9 || map[x + 1][y] == '*')
                {
                    dir = left;
                    // move();
                }
                else
                {
                    x++;
                }
                break;
            case left:
                if (y == 0 || map[x][y - 1] == '*')
                {
                    dir = up;
                    // move();
                }
                else
                {
                    y--;
                }
                break;
        }
    }

    void print()
    {
        cout << x << " " << y << " " << (Direction)dir << endl;
    }

    bool operator < (const Point &point) const
    {
        return x < point.x || y < point.y || (int)(dir) < (int)(point.dir); 
    }
};

void printmap(Point c, Point f)
{
    int i, j;
    for (i = 0; i < 10; i++)
    {
        for (j = 0; j < 10; j++)
        {
            if (i == c.x && j == c.y)
            {
                cout << "C";
            }
            else if (i == f.x && j == f.y)
            {
                cout << "F";
            }
            else
            {
                cout << map[i][j];
            }
        }
        cout << endl;
    }
}

int main(int argc, char const *argv[])
{
    set<pair<Point, Point> > temp;
    string str;
    Point c, f;
    int i, j, t;
    for (i = 0; i < 10; i++)
    {
        getline(cin, str);
        for (j = 0; j < 10; j++)
        {
            if (str[j] == 'C')
            {
                c.x = i;
                c.y = j;
                str[j] = '.';
            }
            if (str[j] == 'F')
            {
                f.x = i;
                f.y = j;
                str[j] = '.';
            }
            map[i][j] = str[j];            
        }
    }

    t = 0;
    while (true)
    {
        if (c.equal(f))
        {
            cout << t;       
            break;
        }
        if (temp.find(make_pair(c, f)) != temp.end())
        {
            cout << 0;
            // c.print();
            // f.print();
            break;
        }
        temp.insert(make_pair(c, f));
        c.move();
        f.move();
        // c.print();
        // f.print();
        // printmap(c, f);
        // cout << endl;
        t++;
    }
       
    return 0;
}
